//
//  MainTabBarController.m
//  BaseProject
//
//  Created by lianjie on 2017/10/31.
//  Copyright © 2017年 lianjie. All rights reserved.
//

#import "MainTabBarController.h"
#import "MainNavController.h"
#import "VTBaseViewController.h"
//#import "HomeViewController.h"
@interface MainTabBarController ()

@end

@implementation MainTabBarController


- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    VTBaseViewController *homePage = [[NSClassFromString(@"ViewController") alloc]init];
    
//    VTBaseViewController *secondPage = [[NSClassFromString(@"OrderViewController") alloc]init];
////
//    VTBaseViewController *thirdPage = [[NSClassFromString(@"JiaMengViewController") alloc]init];
////
//    VTBaseViewController *fourPage = [[NSClassFromString(@"ChongZhiViewController") alloc]init];
//
//    VTBaseViewController *fivePage = [[NSClassFromString(@"OwnerViewController") alloc]init];
    
    
    ///首页
    
    [self addchildVc:homePage title:@"首页" image:@"首页1@1x" selectImage:@"首页@1x"];
    MainNavController *homeNav = [[MainNavController alloc]initWithRootViewController:homePage];
    ///订单
    
//    [self addchildVc:secondPage title:@"订单" image:@"订单1@1x" selectImage:@"订单@1x"];
//    MainNavController *messageNav = [[MainNavController alloc]initWithRootViewController:secondPage];
//
//
//    ///加盟
//    [self addchildVc:thirdPage title:@"加盟" image:@"加盟1@1x" selectImage:@"加盟@1x"];
//    MainNavController *JMNav = [[MainNavController alloc]initWithRootViewController:thirdPage];
//
//    ///充值
//    [self addchildVc:fourPage title:@"钱包" image:@"充值@1x" selectImage:@"充值1@1x"];
//    MainNavController *CZNav = [[MainNavController alloc]initWithRootViewController:fourPage];
//
//
//    ///我的中心
//
//    [self addchildVc:fivePage title:@"我的" image:@"我的1@1x" selectImage:@"我的@1x"];
//    MainNavController *ownerNav = [[MainNavController alloc]initWithRootViewController:fivePage];
    
    self.viewControllers = @[homeNav];
    
}













/**
 
 添加一个子控制器
 
 1、childVc。    子控制器
 2、title。       标题
 3、image         图片
 4、selectImage。  选中的图片
 
 */
-(void) addchildVc:(UIViewController *)childVc title:(NSString *)title image:(NSString *)image selectImage:(NSString *)selectImage
{
    
    
//    [self setValue:[[CustomTabbar alloc]init] forKey:@"tabBar"];
    ///设置tabbar不透明
    
    [[UITabBar appearance] setTranslucent:NO];
    
    ///设置tabbar的颜色
    
    [[UITabBar appearance] setTintColor:WhiteColor];
    
    
    ///设置子控制器上的文字
    
    childVc.title = title;
    
    
    ///设置子控制器的图片
    //状态1
    childVc.tabBarItem.image = [[UIImage imageNamed:image] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    //状态2
    childVc.tabBarItem.selectedImage = [[UIImage imageNamed:selectImage] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    ///imageWithRenderingMode 防止被tint color渲染成蓝色
    
    CGFloat textFont = autoScaleW(24);
    
    ///设置文字样式
    //状态1
    [childVc.tabBarItem setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:textFont],NSForegroundColorAttributeName:BlackColor} forState:UIControlStateNormal];
    //状态2
    [childVc.tabBarItem setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:textFont],NSForegroundColorAttributeName:[UIColor redColor]} forState:UIControlStateSelected];
    
    
    
    
    
    
}







- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
